<?php
require_once(BIB_SMARTY);

/**
 * Classe singleton smarty
 *
 * @author André Coura
 * @since 18/03/2008
 */
class ControlSmarty{

	static private $_objSmarty;

	/**
	 * Construtor privado singleton
	 *
	 * @author André Coura
	 * @since 1.0 - 21/03/2008
	 */
	private function __construct(){
	}

	/**
	 * método responsável por instanciar o objeto smarty caso ele ainda nao tenha sido instanciado
	 *
	 * @author André Coura
	 * @since 1.0 - 21/03/2008
	 */
    private function singleton(){
		self::$_objSmarty = new Smarty();

		self::$_objSmarty->template_dir = TPLS_FILE;
		self::$_objSmarty->compile_dir = TPLS_COMPILA;
		self::$_objSmarty->config_dir = TPLS_FILE."configs/";
		self::$_objSmarty->cache_dir = TPLS_FILE."cache/";
		self::$_objSmarty->register_resource("text", array("text_get_template",
		                                           "text_get_timestamp",
		                                           "text_get_secure",
		                                           "text_get_trusted"));
		self::$_objSmarty->register_function("COMBOBOX","getCombobox");
		self::$_objSmarty->register_function("GRID","getGrid");
		self::$_objSmarty->register_function("EDITOR","getEditor");
		self::$_objSmarty->register_function("MULTBOX","getMultBox");
    }

    /**
	 * método para retornar o objeto smarty
	 *
	 * @author André Coura
	 * @since 1.0 - 21/03/2008
	 */
	public static function getSmarty(){
		if (is_null((self::$_objSmarty)))
      		self::singleton();
		return self::$_objSmarty;
    }

}
?>